//
//  CommetTests.m
//  CommetTests
//
//  Created by tanqilong on 16/5/31.
//  Copyright © 2016年 tanqilong. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "XLNetTest.h"
#import "TestMode.h"
#import "AFNetworking.h"

@interface CommetTests : XCTestCase
{
    NSURLSessionTask * task;
    BOOL _isSetUp;
    
}
@end

@implementation CommetTests

void CrashHandlerExceptionHandler(NSException *exception) {
    
    NSLog(@"%@",[exception userInfo]);
    
    
}

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    __block BOOL isFinished;
    NSString * url = @"http://ipad-bjwb.bjd.com.cn/DigitalPublication/publish/Handler/APINewsList.ashx?date=20131129&startRecord=1&len=5&udid=1234567890&terminalType=Iphone&cid=213";
    [XLNetTest requestWithDic:nil ModeClass:[TestMode class] Url:url Method:RequestMothodGet Success:^(XLBaseNetMode *mode, id json) {
        NSLog(@"%@ %@",mode,json);
        NSLog(@"%@",[NSRunLoop currentRunLoop]);
//         isFinished = YES;
    } Error:^(id json, NSURLResponse *response) {
        NSLog(@"%@ %@",json,response);
    }];
    NSLog(@"%@",[NSRunLoop currentRunLoop]);
    NSDate * date = [NSDate dateWithTimeIntervalSinceNow:10];
    [[NSRunLoop currentRunLoop]runUntilDate:date];
    
    NSTimer * timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timeTest) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop]addTimer:timer forMode:NSDefaultRunLoopMode];
    
    
//    int i = 0;
//    while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true) && !isFinished) {
//        i++;
//    }
    
    
//    
}

-(void)timeTest {
    NSLog(@"1");
}

-(void)test2{
    NSTimer * timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timeTest) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop]addTimer:timer forMode:NSDefaultRunLoopMode];
}


//- (void)testPerformanceExample {
//    // This is an example of a performance test case.
//    [self measureBlock:^{
//        // Put the code you want to measure the time of here.
//    }];
//}

@end


